#include "fileOperation.h"


std::vector<std::vector<int>> FileOperation::getMatrix(const std::string& fileName) {
    FILE* fp;

    fp = fopen(fileName.c_str(), "r");

    char c[4];
    fgets(c, sizeof(int), fp);
    int N = (c[0] - 48);

    for (int i = 1; i < 4; i++) {
        if (c[i] >= '0' && c[i] <= '9')
            N = N * 10 + (c[i] - '0');
        else break;
    }

    std::vector<std::vector<int>> matrix = std::vector<std::vector<int>>(N, std::vector<int>(N, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            fscanf(fp, "%d", &matrix[i][j]);
        }
    }
    fclose(fp);

    return matrix;
};